package com.jiandaoshou.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.andview.refreshview.recyclerview.BaseRecyclerAdapter;
import com.jiandaoshou.R;
import com.jiandaoshou.entry.OrderMonthCount;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/9/29.
 */
public class CaiWuAdapter extends BaseRecyclerAdapter<CaiWuAdapter.CaiWuHodler> {
    public Context context;
    public List<OrderMonthCount> datas=new ArrayList<OrderMonthCount>();

    public CaiWuAdapter(Context context, List<OrderMonthCount> datas) {
        this.context = context;
        this.datas = datas;
    }

    @Override
    public CaiWuHodler getViewHolder(View view) {
        return new CaiWuHodler(view);
    }

    @Override
    public CaiWuHodler onCreateViewHolder(ViewGroup parent, int viewType, boolean isItem) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_caiwuguanli, parent, false);
        CaiWuHodler holder = new CaiWuHodler(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(CaiWuHodler holder, int position, boolean isItem) {
        holder.tv_Month.setText(datas.get(position).getMonth());
        holder.tv_orderacount.setText(datas.get(position).getPrice());
        holder.tv_total.setText("￥"+datas.get(position).getNum());
    }

    @Override
    public int getAdapterItemCount() {
         return datas.size();
    }

    public class CaiWuHodler extends RecyclerView.ViewHolder {
        TextView tv_Month;
        TextView tv_total;
        TextView tv_orderacount;
        public CaiWuHodler(View itemView) {
            super(itemView);
            tv_Month = (TextView) itemView.findViewById(R.id.item_caiwumonth);
            tv_orderacount= (TextView) itemView.findViewById(R.id.item_dingdanshu);
            tv_total= (TextView) itemView.findViewById(R.id.item_dingdanshu);
        }
    }
}
